package com.example.sqlitelogin;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TextView;

import androidx.fragment.app.Fragment;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link BlankFragment1#newInstance} factory method to
 * create an instance of this fragment.
 */
public class BlankFragment3 extends Fragment {


    private static final String ARG_TEXT = "param1";

    // TODO: Rename and change types of parameters
    private String mTextString;


    View rootView;

    public BlankFragment3() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.

     * @return A new instance of fragment BlankFragment1.
     */
    // TODO: Rename and change types and number of parameters
    public static BlankFragment3 newInstance(String param1) {
        BlankFragment3 fragment = new BlankFragment3();
        Bundle args = new Bundle();
        args.putString(ARG_TEXT, param1);

        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mTextString = getArguments().getString(ARG_TEXT);

        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        if(rootView==null){
            rootView= inflater.inflate(R.layout.fragment_blank3, container, false);
        }
        initView();
        return rootView;
    }

    private void initView() {
        Button btf1,btf2,btf3,btf4;
        btf1=rootView.findViewById(R.id.device1);
        btf2=rootView.findViewById(R.id.device2);
        btf3=rootView.findViewById(R.id.device3);
        btf4=rootView.findViewById(R.id.device4);



        btf1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent15=new Intent(getActivity(),SheZi1Activity.class);
                startActivity(intent15);
            }
        });
        btf2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent15=new Intent(getActivity(),SheZi2Activity.class);
                startActivity(intent15);
            }
        });
        btf3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent15=new Intent(getActivity(),SheZi3Activity.class);
                startActivity(intent15);
            }
        });
        btf4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent15=new Intent(getActivity(),SheZi4Activity.class);
                startActivity(intent15);
            }
        });

        Switch mSwitch11 = rootView.findViewById(R.id.s1);
        Switch mSwitch12 = rootView.findViewById(R.id.s2);
        Switch mSwitch13 = rootView.findViewById(R.id.s3);
        Switch mSwitch14 = rootView.findViewById(R.id.s4);
        mSwitch11.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    mSwitch12.setChecked(false);
                    mSwitch13.setChecked(false);
                    mSwitch14.setChecked(false);
                }else {

                }
            }
        });
        mSwitch12.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    mSwitch11.setChecked(false);
                    mSwitch13.setChecked(false);
                    mSwitch14.setChecked(false);
                }else {

                }
            }
        });
        mSwitch13.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    mSwitch12.setChecked(false);
                    mSwitch11.setChecked(false);
                    mSwitch14.setChecked(false);
                }else {

                }
            }
        });
        mSwitch14.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked){
                    mSwitch12.setChecked(false);
                    mSwitch11.setChecked(false);
                    mSwitch13.setChecked(false);
                }else {

                }
            }
        });

    }
}